package com.cz.basetool.ui_work.util.system.application;

/**
 * Created by XinYi on 2018/8/7.
 * 设备配置，用于兼容不同的设备。
 */

public class DeviceConfig {
    private Builder builder;
    public int areaId ;
    public boolean saveLocalLog;           //保存本地日志，包括Locat和ExceptionLogCather的日志
    public String deviceId;                  //设备唯一编号


    public DeviceConfig(Builder builder) {
        this.builder = builder;
        fillDataFromBuilder(builder);
    }

    private void fillDataFromBuilder(Builder builder) {
        this.areaId = builder.areaId;
        this.saveLocalLog = builder.saveLocalLog;
        this.deviceId = builder.deviceId;
    }

    public static class Builder{
        public int areaId ;                 //区域ID，用于升级。
        public boolean saveLocalLog;           //保存本地日志，包括Locat和ExceptionLogCather的日志
        public String deviceId;


        public Builder() {
            this.areaId = -1;
            this.saveLocalLog =  false;
            this.deviceId = "";
        }

        public Builder setSaveLocalLog(boolean saveLocalLog){
            this.saveLocalLog = saveLocalLog;
            return this;
        }

        public Builder setAreaId(int areaId){
            this.areaId = areaId;
            return this;
        }

        public Builder setDeviceId(String deviceId){
            this.deviceId = deviceId;
            return this;
        }

        public Builder build(){
            return  this;
        }

        public DeviceConfig create(){
            return  new DeviceConfig(this);
        }
    }

    public static DeviceConfig getDefaultInstance(){
        return new Builder().create();
    }
}
